﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using HRM.Entity;
using HRM.BIZ;

namespace WebUI.Pages
{
    public partial class UserList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                grvUserList.DataSource = new UserBiz().GetAll();
                grvUserList.DataBind();
            }
        }

        protected void grvUserList_RowCreated(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.Header)
            {
                CheckBox chkAll = new CheckBox();
                chkAll.ID = "chkAll";
                e.Row.Cells[0].Controls.Add(chkAll);
            }
        }

        protected void grvUserList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.Header)
            {
                CheckBox chk = e.Row.FindControl("chkAll") as CheckBox;
                if (chk != null)
                {
                    chk.Attributes.Add("onclick", string.Format("selectAll('{0}')", chk.ClientID));
                }
            }
        }
    }
}
